/**
 * Controller class for the Staff Container.
 */
package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;
public class StaffCTR
{
    private StaffContainer sctr;
    /**
     * Constructor for objects of class StaffCtr
     */
    public StaffCTR()
    {
        sctr = StaffContainer.getSingelton();
    }
    
    /**
     * Finds the the entry in array via the staffs phonenumber.
     * 
     * @param phone persons phonenumber to be used in search.
     */
    public Staff getStaff(String phone)
    {
        Staff staff = sctr.findStaff(phone);
        return staff;
    }
    
    /**
     * Creating a new entry in the staff container.
     * 
     * @param first name sets the first name for the entry
     * @param last name sets the last name for the entry
     * @param address sets the address for the enty
     * @param zipcode sets the zip code for the entry
     * @param city sets the city for the entry
     * @param phoneNo sets the phonenumber for the entry
     * @param salary sets the salary for the entry
     * @param position sets the position for the entry
     */
    public void createStaff(String firstName, String lastName, String address, String zipcode, String city, String phoneNo, double salary, String position)
    {
        Staff staff = new Staff(firstName, lastName, address, zipcode, city, phoneNo, salary, position);
        sctr.addStaff(staff);
    }
    
     /**
     * Deleting a staff with the use of there phonenumber.
     * 
     * @param phone the staffs phonenumber to be used in deleting there information
     */
    public boolean deleteStaff(String phoneNo)
    {
        return sctr.deleteStaff(phoneNo);
    }
    
    /**
     * Lists all staffs in array.
     */
    public ArrayList<Staff> listAllStaff()
    {
        return sctr.listAllStaff();
    }
    
     /**
     * Editing personal information.
     * 
     * @param choise selecting wich part to edit
     * @param newData the data to replace in array
     * @param salary the salary to replace in array
     */
    public void editStaffData(Staff staff, int choice, String newData)
    {
        
        if(choice == 1)
        {
            staff.setPersonFirstName(newData);
        }
        else if(choice == 2)
        {
            staff.setPersonLastName(newData);
        }
        else if(choice == 3)
        {
            staff.setAddress(newData);
        }
        else if(choice == 4)
        {
            staff.setZipCode(newData);
        }
        else if(choice == 5)
        {
            staff.setCity(newData);
        }
        else if(choice == 6)
        {
            staff.setPhoneNo(newData);
        }
        else if(choice == 7)
        {
            staff.setPosition(newData);
        }
    }
}
